﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizzCore;
using log4net;

namespace BizzUI.Forms
{
    public partial class NewRuleForm : Form
    {
        private static readonly ILog auditLog =
                     LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        public NewRuleForm()
        {
            InitializeComponent();
            initNewRuleForm();
        }

        private void initNewRuleForm()
        {
            BizzSystem s = BizzSystem.getInstance();
            comboBoxCond.DataSource = s.getConditions();
            comboBoxTray.DataSource = s.getConcreteOutboxes();
            System.IntPtr icH = global::BizzUI.Properties.Resources.ruler_icon.GetHicon();
            
            this.Icon = Icon.FromHandle(icH);
            
            
            
        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            try
            {
                BizzSystem s = BizzSystem.getInstance();
                s.addRule(textBoxName.Text, textBoxField.Text, (Condition)comboBoxCond.SelectedItem, textBoxExpectedValue.Text, (BizzCommInterfaces.IOutbox)comboBoxTray.SelectedItem);
                this.Dispose();
            }
            catch (Exception ex)
            {
                auditLog.Error(ex.Message);
                MessageBox.Show(ex.Message);
            }
        }

    }
}
